package cn.wellwan.utils;

import javax.servlet.http.HttpServletRequest;

/**
 * Created by kaikai on 2017/2/18.
 */
public abstract class URLUtils {

    public static final String getRequestURL(HttpServletRequest request) {
        String queryString = request.getQueryString();
        if (queryString != null) {
            return request.getRequestURL().append("?").append(queryString).toString();
        }
        return request.getRequestURI();
    }

    public static final String getFullRequestURL(HttpServletRequest request) {
        String base_domain_path=request.getScheme()+"://"+request.getServerName();
        String full_request_path=request.getRequestURL().toString();
        if(!full_request_path.contains("http:")){
            full_request_path=base_domain_path+full_request_path;
        }
        String queryString = request.getQueryString();
        if (queryString != null) {
            full_request_path=full_request_path+"?"+queryString;
        }
        return full_request_path;

    }
}
